![]() |
DrawJustified |
||||
Header: | QuickdrawText.h | Carbon status: | Supported | |
Draws the specified text at the current pen location in the current graphics port, taking into account the adjustment necessary to condense or extend the text by the slop value, appropriately for the script system.
void DrawJustified ( Ptr textPtr, SInt32 textLength, Fixed slop, JustStyleCode styleRunPosition, Point numer, Point denom );
A pointer to the memory location of the beginning of the text to be drawn.
The number of bytes of text to be drawn.
Note that textLength is the number of bytes to be drawn, not the number of characters. Because 2-byte script systems also include characters consisting of only 1 byte, do not simply multiply the number of characters by 2 to determine this value; you must determine and specify the correct number of bytes.
The amount of slop for the text to be drawn. A positive value extends the text segment; a negative value condenses the text segment. Pass the value assessed for this style run based on the proportion returned for it from PortionLine.
The value of this parameter is the number of pixels by which the width of the text segment is to be changed, after the text has been scaled. The slop is a signed value that specifies how much the text is to be extended or condensed. The slop is derived from the calculations made using the proportion returned from the PortionLine function for a style run. To measure or draw text that is not to be extended or condensed, pass a slop value of 0.
The position on the line of this style run. The style run can be the only one on the line, the leftmost on the line, the rightmost on the line, or one between two other style runs. Be sure to pass the same value that you pass to PortionLine.
This parameter specifies the position of the style run on the display line. It is used to determine the proportion of total slop to apply to a style run, measure or draw a line of justified text, identify where to break a line of text, and determine the caret position to mark an insertion point or highlight text.
The style run position parameter is meaningful only for those script systems that use intercharacter spacing for justification. For all other script systems, the parameter exists for future extensibility. Although the style run position parameter is not used, for example, for justifying text in the Roman script system, to allow for future compatibility, you should always specify the appropriate value for it for all calls that take it.
For those script systems that do use intercharacter spacing, space between style runs may be allocated differently depending upon whether the style run is leftmost, rightmost, or between two other style runs. For example, depending on the script system, if a style run occurs at the beginning or end of a line, extra space may not be added to the outer edge of the outermost glyph, whereas if a style run is interior to a line, all of the glyphs of the text may be treated the same: extra space is allocated to both sides of every glyph including those at either end of the style run.
The current implementations of simple script systems such as Roman and Cyrillic do not justify a line of text by changing the width of nonspace characters. Instead, they rely solely on the use of space characters: the same amount of extra width is added to (or subtracted from) every space whether the space is at the beginning or end of the line or interior to it.
A point giving the numerator for the horizontal and vertical scaling factors.
Both numer and denom are point values: numer specifies the numerator for the horizontal and vertical scaling factors, and denom specifies the denominator for the horizontal and vertical scaling factors. Together, these values specify the scaling factors for the text: numer.v over denom.v gives the vertical scaling (height), and numer.h over denom.h gives the horizontal scaling factors (width). You need to specify values for numer and denom even if you are not scaling the text. For unscaled text, you can specify scaling factors of 1, 1. Be sure to pass the same value that you pass to PortionLine.
A point giving the denominator for the horizontal and vertical scaling factors. Be sure to pass the same value that you pass to PortionLine.
The DrawJustified function is similar to the DrawText function, except that you use it to draw text that is expanded or condensed by the number of pixels specified by slop. The DrawJustified function is most commonly used to draw a line of justified text.
The DrawJustified function draws the specified text in the font, size, and style of the current graphics port, taking into account any scaling factors, and it distributes the slop appropriately for the script system. Regardless of the line direction of the text to be drawn, you place the pen at the left edge of the line before calling DrawJustified for the first style run. For all subsequent style runs on that line, QuickDraw advances the pen appropriately.
If DrawJustified changes the width of spaces, it temporarily resets the space extra (spExtra) value. It adds to the current value of the field, if any, the amount of extra space to be applied to each space character within the range of text in order to justify the text, based on calculations that take into account the slop value and all of the text characteristics. On exit, DrawJustified restores the original value.
The DrawJustified function works with text in all script systems. For example, to depict justified Arabic text, DrawJustified uses extension bars to create the additional width that is distributed as slop within a style run.
For 1-byte complex script systems, DrawJustified substitutes the proper ligatures, reversals, and compound characters as needed.
For 2-byte script systems that do not use space characters to delimit words, DrawJustified distributes the slop value in a manner appropriate to the script system. For script systems, such as Japanese, that use ideographic characters, DrawJustified distributes the additional screen pixel width appropriately for the text representation.
The DrawJustified function may move memory; do not call this function at interrupt time.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)